//
//  MessageListViewController.m
//  JHZWeiBo
//
//  Created by 张德培 on 16/5/27.
//  Copyright © 2016年 蒋晨成. All rights reserved.
//

#import "MessageListViewController.h"
#import "AltMyViewController.h"

#import "MessageListModel.h"
#import "MessageListTableViewCell.h"
#import "MySearchBar.h"
#import "MyTableView.h"

@interface MessageListViewController ()<UITableViewDelegate,UITableViewDataSource>
@property (nonatomic,strong)MyTableView *tableview;
@property (nonatomic,strong)NSArray *listArray;
@property (nonatomic,strong)NSArray *imageArray;
@property (nonatomic,strong)NSArray *titleArray;
@end

@implementation MessageListViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    // nav
    self.navigationItem.title = @"消息";
    self.navigationController.navigationBar.tintColor = [UIColor grayColor];
    // 发现群
    UIBarButtonItem *discoverButton = [[UIBarButtonItem alloc]initWithTitle:@"发现群" style:UIBarButtonItemStylePlain target:self action:@selector(discoverButtonAction:)];
    self.navigationItem.leftBarButtonItem = discoverButton;
    
    // 聊天
    UIBarButtonItem *chatButton = [[UIBarButtonItem alloc]initWithTitle:@"聊天" style:UIBarButtonItemStylePlain target:self action:@selector(chatButtonAction:)];
    self.navigationItem.rightBarButtonItem = chatButton;
    
    // tableview
    self.tableview = [[MyTableView alloc]initWithFrame:CGRectMake(0, 0, kWidth, kHeight) style:UITableViewStylePlain];
    self.tableview.delegate = self;
    self.tableview.dataSource = self;
    [self.view addSubview:_tableview];
    [_tableview registerClass:[MessageListTableViewCell class] forCellReuseIdentifier:@"Message"];
    
    // 搜索栏
    MySearchBar *searchBar = [[MySearchBar alloc]initWithFrame:CGRectMake(0, 0, kWidth, 50)];
    _tableview.tableHeaderView = searchBar;
    
//    uid=2157199532
    
    _imageArray = @[@"艾特",@"chat",@"赞"];
    _titleArray = @[@"@我的",@"评论",@"赞"];
    
    
//   评论-》关注人的 https://api.weibo.com/2/comments/to_me.json?access_token=2.00qI5z2C01BiGcd1d0fb2aaaDQHuzD&filter_by_author=1
//   评论——》所有评论https://api.weibo.com/2/comments/to_me.json?access_token=2.00qI5z2C01BiGcd1d0fb2aaaDQHuzD
//    评论 —— 》我发出的 https://api.weibo.com/2/comments/by_me.json?access_token=2.00qI5z2C01BiGcd1d0fb2aaaDQHuzD
//    @我 ——》所有评论https://api.weibo.com/2/comments/mentions.json?access_token=2.00qI5z2C01BiGcd1d0fb2aaaDQHuzD
//    @我-》关注人的评论https://api.weibo.com/2/comments/mentions.json?access_token=2.00qI5z2C01BiGcd1d0fb2aaaDQHuzD&filter_by_author=1
    
}

#pragma marks --- 发现群点击方法 ---
- (void)discoverButtonAction:(UIBarButtonItem *)button{
    
}
#pragma marks --- 聊天点击方法 ---
- (void)chatButtonAction:(UIBarButtonItem *)button{
    
}
#pragma marks --- 返回行高 ---
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
    return 80;
}
#pragma marks --- 返回行数 ---
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    return 10;
}
#pragma marks --- 返回cell ---
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    MessageListTableViewCell *cell = [_tableview dequeueReusableCellWithIdentifier:@"Message" forIndexPath:indexPath];
    NSArray *colourArray = @[[UIColor cyanColor],[UIColor brownColor],[UIColor orangeColor]];
    if (indexPath.row < 3) {
        UIImage *image = [UIImage imageNamed:_imageArray[indexPath.row]];
        cell.headimage.image = image;
        cell.headimage.backgroundColor = colourArray[indexPath.row];
        cell.titleLabel.text = _titleArray[indexPath.row];
        cell.label.hidden = NO;
    }
    return cell;
}
#pragma maeks --- 点击cell方法 ---
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
    if (indexPath.row == 0) {
        AltMyViewController *vc= [[AltMyViewController alloc]init];
        vc.arrayTitle = @[@"所有微博",@"关注人的微博",@"原创微博",@"所有评论",@"关注人的评论"];
        vc.arrayURL = @[@"",@"",@"",@"",@""];
        [self.navigationController pushViewController:vc animated:YES];
    }else if (indexPath.row == 1){
        
        AltMyViewController *vc = [[AltMyViewController alloc]init];
        vc.arrayTitle = @[@"所有评论",@"关注的人",@"我发出的"];
        vc.arrayURL = @[@"",@"",@""];
        [self.navigationController pushViewController:vc animated:YES];
    }
}
#pragma marks --- 网络请求 ---

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
